#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import xmlrpclib

url='http://127.0.0.1:8069'
db='test_3_2'
# db='demo'
username='admin'
password='1'


# 连接信息
# xmlrpc/2/common
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()

# 用户权限认证
uid = common.authenticate(db, username, password, {})

# 调用方法
# xmlrpc/2/object
models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

# order = models.execute_kw(db, uid, password,
#       'sale.order', 'search_read',
#       [[['name', '=', 'SO113']]]
#       , {'limit':1,'order':'id desc'})

# print(order[0]['order_line'])


# method='update_order_line'
# models.execute_kw(db, uid, password,
#       'sale.order', method,
#       [order[0]['id']], {})

# method='button_update_special'
# models.execute_kw(db, uid, password,
#       'sale.order', method,
#       [order[0]['id']], {})

# model = 'ir.model.data'
# method = 'get_object_reference'
# print(
#     models.execute_kw(db, uid, password,
#         model, method,
#         ['sale_order_project','product_category_all_saleable_main'])
# )


# model="product.template"
# method="search_read" 

# print( models.execute_kw(db, uid, password,
#     model, method,
#     [[['name', '=', u'板材']
#         ,['categ_id.id','child_of',9]
#     ]])
# )
# print(ptl)

# models.execute_kw(db, uid, password,
#       'sale.order', 'update_order_other_line',
#       [order[0]['id']]
#       , {'exclude_product_name':['板材']})
model='ir.model.data'
method='get_object_reference'
result = models.execute_kw(db, uid, password,
      model, method,
      ['sale_order_project','sale_bancai_form_view'], {})
print(result)

